<?php
header('content-type:text/html; charset=utf-8');
session_start();


if ($_FILES["file"]["error"] > 0)
{
	echo "上传错误: " . $_FILES["file"]["error"] . "<br />";
}
if (file_exists("img/" . $_FILES["file"]["name"]))
{
	echo $_FILES["file"]["name"] . " 此文件已经存在，请更换其他文件，或更改此文件的文件名。 ";
}
else
{
	@$src="img/" . $_FILES["file"]["name"];
	move_uploaded_file($_FILES["file"]["tmp_name"],	$src);
	
	
	@$name=$_REQUEST['name'];
	@$price=$_REQUEST['price'];
	@$lei=$_REQUEST['lei'];
	
	
	
	$pdo=new PDO('mysql:dbname=can;charset=utf8','root');
	
	$s=$pdo->prepare('insert into cai(name,price,src,leiId) values(:aa,:bb,:cc,:dd)');
	if($s->execute(array('aa'=>$name,'bb'=>$price,'cc'=>$src,'dd'=>$lei))){
		header('content-type:text/html; charset=utf-8');
		header('Refresh:0;url=/th4.php');
		echo "ok";
	}else {
		echo "error";
	}
	echo "img/" . $_FILES["file"]["name"];
}
/*
*/